package com.longge;

import java.util.HashSet;

/**
 * @program: my-code
 * @description:
 * @author: longge
 * @create: 2021-03-05 23:19
 */
public class NumJewelsInStones {
    public int numJewelsInStones(String jewels, String stones) {

        char[] gemstone = jewels.toCharArray();
        char[] stone = stones.toCharArray();
        HashSet<Character> characters = new HashSet<>();
        int res = 0;
        for (char c : gemstone) {
            characters.add(c);
        }
        for (char c : stone) {
            if (characters.contains(c)){
                res++;
            }
        }
        return res;
    }

    public static void main(String[] args) {
        int i = new NumJewelsInStones().numJewelsInStones("aA", "aAAbbbb");
        System.out.println(i);
    }
}
